# Examples Makefile

CC = gcc
CFLAGS = -Wall -Wextra -std=c99 -g -I../include
LIBPATH ?= ../build
LDFLAGS = -L$(LIBPATH) -lgudb -lpthread -lz

# Examples to build
EXAMPLES = tutorial_basic server_demo

all: $(EXAMPLES)

# Build the main library first
$(LIBPATH)/libgudb.a:
	$(MAKE) -f ../build/Makefile

tutorial_basic: tutorial_basic.c $(LIBPATH)/libgudb.a
	$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)

server_demo: server_demo.c $(LIBPATH)/libgudb.a
	$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)

clean:
	rm -f $(EXAMPLES) *.o

install:
	@echo "Examples built successfully!"
	@echo ""
	@echo "Available examples:"
	@echo "  ./tutorial_basic  - Basic database operations tutorial"
	@echo "  ./server_demo     - MySQL server demo"

.PHONY: all clean install